<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script type="module">
import {CredentialManagerError} from '/gen/third_party/blink/public/mojom/credentialmanager/credential_manager.mojom.m.js';
import {MockCredentialManager} from './resources/mock-navigator-credentials.js';

const mockCredentialManager = new MockCredentialManager;

add_completion_callback(() => {
  mockCredentialManager.reset();
});

promise_test(function (t) {
  mockCredentialManager.setError(CredentialManagerError.PENDING_REQUEST);
  return promise_rejects_dom(t, "InvalidStateError", navigator.credentials.get({ password: true }));
});
promise_test(function (t) {
  mockCredentialManager.setError(CredentialManagerError.UNKNOWN);
  return promise_rejects_dom(t, "NotReadableError", navigator.credentials.get({ password: true }));
});
promise_test(function (t) {
  return promise_rejects_js(t, TypeError, navigator.credentials.get({
      mediation: "invalid"
  }));
});
</script>
